using System;
using System.Collections.Generic;
using System.Text;
using PH.Common;

namespace Hoshimi
{
    public class CollectorBot_CollectAZNState : State
	{
		#region Singleton

		// Fields
		protected static CollectorBot_CollectAZNState instance;

		// Constructor
		protected CollectorBot_CollectAZNState() : base() { }

		// Methods
		public static CollectorBot_CollectAZNState Instance()
		{
			// Uses "Lazy initialization"
			if( instance == null ) 
				instance = new CollectorBot_CollectAZNState();

			return instance;
		}

		#endregion

		public override bool Play( Unit unit )
		{
			CollectorBot bot = (CollectorBot) unit;

			bot.SetName("CollectToAZN");

            if(bot.IsFull())
            {
                unit.myStateMachine.ChangeState( CollectorBot_MoveToHoshimiState.Instance() );
                return true;
            }

			// We cant give order to the bot. We stop
			if ( bot.State != NanoBotState.WaitingOrders ) 
			{
				return true;
			}

            if (!bot.Collect())
            {
                unit.myStateMachine.ChangeState( CollectorBot_MoveToAZNState.Instance() );
                return true;
            }

			unit.myStateMachine.ChangeState( CollectorBot_MoveToHoshimiState.Instance() );
			return false;
		}
	}
}
